home *** CD-ROM | disk | FTP | other *** search
/ Champak 128 / Vol 128 (Damaged).iso / games / boiler_b.swf / scripts / DefineSprite_272 / frame_1 / DoAction.as
Encoding:
Text File  |  2011-03-26  |  1.9 KB  |  97 lines

  1. var pNum = Number(this._name.slice(6,-3));
  2. var pX;
  3. var pY;
  4. var pState;
  5. var pSpd;
  6. var pLeftLimit;
  7. var pRightLimit;
  8. var pAnim;
  9. this.setUp = function(x, y, toleft, toright, spd)
  10. {
  11.    var _loc1_ = this;
  12.    _loc1_.pX = x * 16;
  13.    _loc1_.pY = y * 16;
  14.    _loc1_.pLeftLimit = _loc1_.pX - toleft * 16;
  15.    _loc1_.pRightLimit = _loc1_.pX + toright * 16;
  16.    _loc1_.pSpd = spd;
  17.    _loc1_.pState = "active";
  18.    _loc1_.pAnim = new Array(0,2);
  19. };
  20. this.onEnterFrame = function()
  21. {
  22.    var _loc1_ = this;
  23.    if(pState == "active")
  24.    {
  25.       pX += pSpd;
  26.       if(pX > pRightLimit || pX < pLeftLimit)
  27.       {
  28.          pSpd = - pSpd;
  29.          pX += pSpd;
  30.       }
  31.       if(pSpd < 0)
  32.       {
  33.          _loc1_._xscale = -100;
  34.       }
  35.       else
  36.       {
  37.          _loc1_._xscale = 100;
  38.       }
  39.       pAnim[0] = pAnim[0] + 1;
  40.       if(pAnim[0] > 1)
  41.       {
  42.          pAnim[0] = 0;
  43.          pAnim[1] = pAnim[1] + 1;
  44.          if(pAnim[1] > 5)
  45.          {
  46.             pAnim[1] = 0;
  47.          }
  48.          _loc1_.gotoAndStop(pAnim[1] + 2);
  49.       }
  50.       if(Math.random() * 100 < 2)
  51.       {
  52.          if(_loc1_._parent["bullet" + pNum + "_mc"].pState == "idle")
  53.          {
  54.             _loc1_.fire();
  55.          }
  56.       }
  57.    }
  58.    else if(pState == "firing" || pState == "resting")
  59.    {
  60.    }
  61. };
  62. this.setPos = function(ty, tdir)
  63. {
  64.    this._x = pX + 38;
  65.    this._y = pY - ty;
  66. };
  67. this.fire = function()
  68. {
  69.    pState = "firing";
  70.    this.gotoAndPlay("shoot");
  71. };
  72. this.teaBreak = function()
  73. {
  74.    pState = "resting";
  75.    this.gotoAndPlay("sit");
  76. };
  77. this.resetMe = function()
  78. {
  79.    var _loc1_ = this;
  80.    switch(pNum)
  81.    {
  82.       case 0:
  83.          _loc1_.setUp(10,23,9,17,4);
  84.          break;
  85.       case 1:
  86.          _loc1_.setUp(34,41,6,4,3);
  87.          break;
  88.       case 2:
  89.          _loc1_.setUp(25,53,1,16,4);
  90.          break;
  91.       case 3:
  92.          _loc1_.setUp(30,92,10,10,-3);
  93.    }
  94. };
  95. this.resetMe();
  96. stop();
  97.